package com.test.sdk.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.test.sdk.OrderUtil;
import com.test.sdk.common.pojo.Order;
import com.test.sdk.dao.OrderDAO;
import com.test.sdk.service.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;

@Service
public class OrderServiceImpl implements OrderService {

    @Autowired
    private OrderDAO orderDAO;

    @Override
    public Order addOrder(int userId,int amount,String extInfo) {
        Order order=new Order();
        order.setUserId(userId);
        order.setAmount(amount);
        order.setExtInfo(extInfo);
        order.setOrderNum(OrderUtil.getOrderId());
        orderDAO.addOrder(order);
        return order;
    }

    @Override
    public void updateOrder(Order order) {
        orderDAO.updateOrder(order);
    }

    @Override
    public Order getOrderByNum(String num) {
        return orderDAO.getOrderByNum(num);
    }
}
